<?php
include_once XXF_RUNEXCEL;
class Pxs_ctl extends Ctl{
    function __construct(){
    }
    function main(array $xxfget) {
        $this::sessver();
        $type=!empty($xxfget['type'])?$xxfget['type']:false;
		$pid=!empty($xxfget['pid'])?$xxfget['pid']:-1;
        if(!$type){
        	$pxb=xdb::getInstance()->getarray('select * from peixunban order by id desc');
			$sqlstr='select px.id as puid,pname,puname,mphone,workunit,ptype,idcard from peixunxueyuan as px,peixunban as pb where px.pid=pb.id';
			if($pid=="all"){
				$pxy=xdb::getInstance()->getarray($sqlstr);
			}else{
				$pxy=xdb::getInstance()->getarray($sqlstr.' and px.pid='.$pid);
			}
        	$this::show('pxs',compact('pid','pxy','pxb'));
        }elseif($type=="down"){
            $pid=$xxfget['pid'];
            $pname="全部班级";
            if($pid!="all"){
                $pname=xdb::getInstance()->getvar("select pname from peixunban where id=".$pid);
            }
            $header=array("班级","培训类型","姓名","身份证","人员类型","成绩","补考成绩","电话","专业","民族","职称","职务","学历","单位","单位地址","开始培训","结束培训","备注");
            $sqlstr="select pname,xinfuxun,puname,idcard,ptype,chengji,bukaochengji,mphone,zhuanye,minzu,zhicheng,zhiwu,wenhua,workunit,address,stime,etime,beizhu from peixunban as pb,peixunxueyuan as px where pb.id=px.pid ".($pid=="all"?"":"and px.pid=".$pid);
            $array=xdb::getInstance()->getarray($sqlstr,"ARRAY_N");
            $re=new RunExcel();
            $re->createExcel();
            $re->setActiveSheetTitle("培训信息");
            $re->setHeader($header);
            $re->setBody($array);
            $re->down($pname);
        }
    }
}